<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文件上传测试页面</title>
</head>
<body>


<form action="files/add" method="post" enctype="multipart/form-data" >
<div>
    上传:<input type="file" name="files"><br>

    <input type="submit" value="提交">
</div>
</form>

<form action="javascript:void(0)" method="post">
    <input type="text" name="username"><br>
    <input type="text" name="password"><br>
    <input type="checkbox" name="roleList" value="普通用户">普通用户<br>
    <input type="checkbox" name="roleList" value="VIP">VIp<br>
    <input type="submit" value="提交">
</form>

<form action="/user/register" method="post">
    <input type="text" value="请输入验证码"><img id="checkCode" src="user/checkCode" onclick=check()>
</form>

<script src="jquery-3.3.1/jquery-3.3.1.min.js"></script>
<script>



    window.onload = function () {
        var req = new XMLHttpRequest();
        req.open('GET', "http://localhost:8080/user/checkCode", false);
        req.send(null);
        var headers = req.getAllResponseHeaders().toLowerCase();
        //alert(headers);

        var data = "username=wdtt10" +  "&password=a123456" +  "&email=3181870632@qq.com" +  "&checkCode=123456";
        //ajax发送请求头
        $.ajax(
            {
                type:"POST",
                data:data,
                url:"http://localhost:8080/user/register",
                beforeSend:function (request) {
                    //将token带回
                    request.setRequestHeader("checkId",req.getResponseHeader("checkId"))
                },
                success:function (data) {

                },
				dataType:"json"
            }
        )

    }

  function check(){

      var checkCode = document.getElementById("checkCode");
      // checkCode.setAttribute("src","user/checkCode?"+new Date().getTime());
      checkCode.src="user/checkCode?"+new Date().getTime();
  }


</script>
</body>
</html>